﻿using System;
using System.Linq;
using Lt.Engine.Scene;
using RayDen.Library.Components;
using RayDen.Library.Core.Primitives;
using RayDen.RayEngine.Core.Types;
using RayDen.RayEngine.Data;

namespace Lt.Engine.Entity
{
    public class MeshShape : BaseTriangleMeshInfo, IShape
    {
        public MeshShape(string name, SceneDataInfo scene) : base(scene.Meshes.FirstOrDefault(item => item.MeshName.Equals(name, StringComparison.InvariantCultureIgnoreCase)))
        {
        
        }

        public MeshShape(BaseTriangleMeshInfo m)
            : base(m)
        {
            
        }

        public AABB GetBounds()
        {
            return this.Bounds;
        }

        float IShape.Area()
        {
            return this.Area;
        }

        public TriangleDataInfo[] Refine(LtGeoData data)
        {
            return data.Triangles.ToList().GetRange(this.StartTriangle, this.TrianglesCount).ToArray();
        }
    }
}